<template>
	<view>
		<uni-nav-bar statusBar :border='false' color="#fff" fixed :backgroundColor='backgroundColor'>
			<block slot="left">
				<view class="flex-row-flex-start">
					<image class="logo" src="/static/common/logo.png" mode=""></image>
					<view class="topTitle">
					通勤车
					</view>

				</view>
			</block>
		</uni-nav-bar>
		<view class="topView">
			<view class="infoView" style="margin-top: 200rpx;">
				<view class="flex-column-center" >
					<image class="header" :src="userinfo.avatar" mode=""></image>
					<view class="name">
						{{userinfo.nickname}}
					</view>
				</view>
			<!-- 	<view class="item1 flex-row-space-between">
					<view class="left">
						性别
					</view>
					<view class="right flex-row-flex-end">
						男
						<uni-icons type="right" color="#B7B7B7" size="20"></uni-icons>
					</view>
				</view> -->
				<view class="line">
					
				</view>
				<view class="item1 flex-row-space-between">
					<view class="left">
						手机号
					</view>
					<view class="right flex-row-flex-end">
						{{userinfo.mobile}}
						
					</view>
				</view>
				<view class="line">
					
				</view>
				<view @click="roleClick()" class="item1 flex-row-space-between">
					<view class="left">
						身份
					</view>
					<view class="right flex-row-flex-end">
						
						<text v-if="userinfo.group_id==1">在册人员</text>
						<text v-if="userinfo.group_id==2">非在册人员</text>
						<text v-if="userinfo.group_id==3">司机</text>
						<uni-icons v-if="userinfo.group_id==1||userinfo.group_id==2" type="right" color="#B7B7B7" size="20"></uni-icons>
					</view>
				</view>
			</view>
			
		</view>
		<view @click="buttonClick()" class="button flex-column-center">
			退出登录
		</view>



	</view>
</template>

<script>
	import {
		mapActions,
		mapState
	} from "vuex";
	import {
		profile,
	} from '@/api/index.js'
	export default {
		components: {},
		computed: {

		},
		data() {
			return {
				userinfo:{},
				list: [],
				title: "",
				backgroundColor: 'ffffff00',
				list: [],
				data: {}

			}
		},
		computed: {
			...mapState([
				'baseColor'
			]),
		},
		onPageScroll(e) {
			if (e.scrollTop > 20) {
				this.backgroundColor = "#AED0FC"
			} else {
				this.backgroundColor = "#ffffff00"
			}
		},
		onShow() {
this.userinfo=uni.getStorageSync('userinfo')
			this.profile()
		},
		onLoad(e) {
			
			// this.loadData()
		},
		//下拉刷新
		onPullDownRefresh() {


		},
		//加载更多
		onReachBottom() {

		},
		onPageScroll(e) {
			// if (e.scrollTop > 20) {
			// 	this.backgroundColor = "#FBF9FF"
			// } else {
			// 	this.backgroundColor = "#ffffff00"
			// }
		},
		methods: {
			roleClick(){
				if(this.userinfo.group_id==3||this.userinfo.group_id==0){
					return
				}
				uni.navigateTo({
					url:'/pages/index/setRole'
				})
			},
			profile() {
			
				var data = {
					
				}
				profile(data).then(res => {
					
					uni.setStorageSync('userinfo', res.data)
				this.userinfo=uni.getStorageSync('userinfo')
				
				
				})
				},
			buttonClick(){
				uni.removeStorageSync('token')
				uni.navigateTo({
					url:'/pages/login/login'
				})
			},
			loadData() {

				var data = {
					id: this.id
				}
				forum_list(data).then(res => {
					this.list = res.data.data
				})
			},


		}
	}
</script>

<style lang="scss">
	.infoView{
		margin: 30rpx;
		padding: 40rpx 30rpx;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}
	.header{
		margin-top: -130rpx;
		width: 160rpx;
		height: 160rpx;
		background: #E3F1FE;
		border-radius: 50%;
		border: 4rpx solid #FFFFFF;
	}
	.name{
		margin: 30rpx 0;
		font-weight: 500;
		font-size: 36rpx;
		color: #333333;
	}
	.item1{
		height: 96rpx;
	}
	.left{
		font-weight: 500;
		font-size: 30rpx;
		color: #333333;
	}
	.right{
		font-weight: 500;
		font-size: 30rpx;
		color: #B7B7B7;
	}
	.button{
		margin: 260rpx 30rpx;
		height: 96rpx;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		font-weight: 400;
		font-size: 30rpx;
		color: #333333;
	}
</style>